package wrapper.homework;

import java.util.Scanner;

/**
 * @Author Justin Parker
 * @Date 2024/7/12 0012 20:22
 * @Version 1.0
 */
public class Test05 {
    public static void main(String[] args) {

        Person p = new Person();
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入姓名:");
		String name = scanner.nextLine();
        p.setName(name);
		if(p.getName().trim().length()==0||p.getName()==null) {
			System.out.println("姓名不能为空!");
            return;
		}
		System.out.println("请输入年龄:");
		int age = scanner.nextInt();

		if(age>0 && age<100) {
            p.setAge(age);
		}else{
            System.out.println("年龄不合法!");
            return;
		}

		System.out.println("姓名:"+p.getName());
		System.out.println("年龄:"+p.getAge());
    }


    }


    class Person {
        private String name;
        private int age;

        public Person() {
        }



        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }
    }


